import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import html from 'vite-plugin-html'
import vueJsx from '@vitejs/plugin-vue-jsx'

let VITE_ENV = loadEnv(process.env.NODE_ENV, process.cwd())

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx(), html({
    minify: process.env.NODE_ENV === 'production',
    inject: {
      // Inject data into ejs template
      injectData: {
        title: VITE_ENV.VITE_APP_NAME,
        appName: VITE_ENV.VITE_APP_NAME
      }
    },
  })],
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@/styles/_variables.scss";`
      }
    }
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, '/src')
    },
  },
  server: {
    // open: true,
    proxy: {
      '/show': 'http://127.0.0.1:7001'
    }
  },
})
